package com.housediyadmin.view.components
{
	import com.housediyadmin.model.ListTypeModel;
	
	import flash.events.MouseEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author liaoruohuai
	 * 
	 */
	public class EditLabelMediator extends Mediator
	{
		private var isDoorEdit:Boolean;
		private var isWindowEdit:Boolean;
		private var isFloorEdit:Boolean;
		
		[Inject]
		public var view:EditLabel;
		
		[Inject]
		public var model:ListTypeModel;
		
		override public function onRegister():void
		{
			switch (view.id)
			{
				case "doorEdit":
					isDoorEdit = false;
					view.addEventListener(MouseEvent.CLICK, doorEditMouseClick);
					break;
				case "windowEdit":
					isWindowEdit = false;
					view.addEventListener(MouseEvent.CLICK, windowEditMouseClick);
					break;
				case "floorEdit":
					isFloorEdit = false;
					view.addEventListener(MouseEvent.CLICK, floorEditMouseClick);
					break;
			}
		}
		public function doorEditMouseClick(event:MouseEvent):void
		{
			if (!isDoorEdit) 
			{
				view.text = "Done Edit";
				isDoorEdit = true;
			}
			else
			{
				view.text = "Edit";
				isDoorEdit = false;
			}
		}
		
		public function windowEditMouseClick(event:MouseEvent):void
		{
			if (!isWindowEdit) 
			{
				view.text = "Done Edit";
				isWindowEdit = true;
			}
			else
			{
				view.text = "Edit";
				isWindowEdit = false;
			}
		}
		
		public function floorEditMouseClick(event:MouseEvent):void
		{
			if (!isFloorEdit) 
			{
				view.text = "Done Edit";
				isFloorEdit = true;
			}
			else
			{
				view.text = "Edit";
				isFloorEdit = false;
			}
		}
	}
}